page_outattemp = (state={},action)->
  switch action.type
    when 'OUTATTEMP/GET_LIST_START'
      Object.assign {},state,{isLoading:true}
    when 'OUTATTEMP/GET_LIST_COMPLETED'
      list = state.list.concat(action.payload.list)
      index = 0
      for item in list
        item.sortNum = ++index
      Object.assign {},state,{
        list:list
        isLoading:false
        pageIndex:if action.payload.list.length > 0 then state.pageIndex+1 else state.pageIndex
        completed:action.payload.list.length < 20
      }
    when 'OUTATTEMP/REFRESH_LIST_START'
      Object.assign {},state,{
        list:[]
        isLoading:false
        refreshing:true
        completed:false
      }
    when 'OUTATTEMP/REFRESH_LIST_COMPLETED'
      list = action.payload.list
      index = 0
      for item in list
        item.sortNum = ++index
      Object.assign {},state,{
        list:list
        isLoading:false
        pageIndex:1
        refreshing:false
        lastFetchTime:action.payload.lastFetchTime
        completed:true
      }
    else
      state

module.exports = page_outattemp
